class Pg::WeeklyResult < Pg::Connect
  belongs_to :weekly, :class_name => "Pg::Weekly"
  belongs_to :sp_type, :class_name => "Pg::SpType"
  belongs_to :weekly_result_work, :class_name => "Pg::WeeklyResultWork"

  ['wid', 'name', 'wtype', 'author'].each do |n|
    unless self.column_names.include?(n)
      eval "attr_reader(:#{n});def #{n};@#{n} ||= weekly_result_work.#{n};end"
    end
  end

  def work
    Work.find_by_wid wid
  end
  
  #收藏率
  def stow_ratio
    format("%.2f", stows * 100.0 / clicks).to_f
  end
end
